//
//  ViewController.m
//  02-UIViewController
//
//  Created by dllo on 16/7/15.
//  Copyright © 2016年 YMJ. All rights reserved.
//

#import "ViewController.h"
#import "PresentViewController.h"
@interface ViewController ()
@property (nonatomic, strong) UIView *subview;
@end

@implementation ViewController
// 加载self.view(UIViewController 自带的)
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // 不要在此创建视图
        // 只能进行相关数据操作
    }
    return self;
}
- (void)loadView {
    [super loadView];
    NSLog(@"哎哟");
}
// 自定义创建
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    /**self.view = nil;
    NSLog(@"疼");
    NSLog(@"%@",self.view);*/
    self.view.backgroundColor = [UIColor redColor];
   
    
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
     PresentViewController *preVC = [[PresentViewController alloc] init];
    preVC.modalTransitionStyle = 3;
    [self presentViewController:preVC animated:YES completion:^{
        
        
    }];
}
// self.view 当调用getter方法时,不能为空 null_resettable,如果为空,将重走 [super loadView]的方法 也就是loadView.此时的getter相当于懒加载
// 例如subview的getter放啊

/**- (UIView *)view{
    if (_subview == nil) { // getter 判断是否为空
        self.subview = [UIView new]; //初始化方法
        [self loadView]; //loadView方法
    }
    return _subview;
}*/
- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];//记住别忘了写上super
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
    // 释放部分内存
    // 把为显示在屏幕上的资源置空
}

@end
